<!--
 * @Author       : xiangmin
 * @File         : 日期范围封装，为了解决在表单中后端数据将一个时间范围拆成两个字段
 * @Date         : 2023-07-06 19:15:46
 * @LastEditors  : xiangmin
 * @LastEditTime : 2023-11-24 15:15:13
-->
<template>
	<a-range-picker
		:value="dataRane"
		@change="handleDateChange"
		v-bind="$attrs"
	/>
</template>

<script setup lang="ts">
const startDate = defineModel('startDate', { default: '', required: false })
const endDate = defineModel('endDate', { default: '', required: false })

const dataRane = ref<any>([startDate.value, endDate.value])
watch([startDate, endDate], value => {
	dataRane.value = [value?.[0], value?.[1]]
})
const handleDateChange = data => {
	startDate.value = data?.[0]
	endDate.value = data?.[1]
}
</script>
